// pages/public/userCourses.js
const app = getApp()
var CONFIG = require("../../config/config.js");
var share = require("../../utils/share.js");
Page({

    /**
     * 页面的初始数据
     */
    data: {
        uid:'',
        nowpage:0,
        courseList:[],
        coursetype:2,
        threefalse:false,
    },
    // hideloadingfalse() {
    //     var that = this;
    //     console.log(8999)
    //     wx.hideLoading();
    // },

      /**
       * 生命周期函数--监听页面加载
       */
    onLoad: function (options) {
        var that = this;
        that.setData({
            uid:options.user_id
        })
    },
    onShow(){
        var that = this;
        that.userCourseList();
    },

    // 学员的选课记录
    userCourseList(){
        var that = this;
        wx.showLoading({
            title: '加载中~',
        })
        that.setData({
            threefalse:false,
        })
        var recorddataall = that.data.recorddataall;
        var identity = app.globalData.identity;
        if (Number(identity)==1){
            var obj = {
                user_id: that.data.uid,
                nowPage: that.data.nowpage,
                // count:5,
            }
            var url = 'crmapi/Student/StuCourse'
        }else{
            var obj = {
                uid:that.data.uid,
                consultant_id:app.globalData.admin_id,
                nowPage:that.data.nowpage,
                // count: 5,
            }
            if (Number(identity) == 3) {
                var url = 'crmapi/Learn/userCourseList'
            }else{
                var url = 'crmapi/user/userCourseList'
            }
        }
        share.wxRequest(url,obj,function(res){
            if(Number(res.data.errcode)==0){
                var data = res.data.data;
                that.setData({
                    courseList:data
                })
                setTimeout(function(){
                    const child = that.selectComponent("#the-id").showMyTips(data, that.data.nowpage);
                    wx.hideLoading();
                },500)
            }else{
                wx.hideLoading();
            }
            that.setData({
                threefalse:true,
            })
        })
    },
    

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {
        var that = this;
        that.setData({
            nowpage: that.data.nowpage + 1,
        })
        // 学员的选课记录
        that.userCourseList();
    },

      /**
       * 生命周期函数--监听页面隐藏
       */
      onHide: function () {

      },

      /**
       * 生命周期函数--监听页面卸载
       */
      onUnload: function () {

      },

      

      

      /**
       * 用户点击右上角分享
       */
      onShareAppMessage: function () {

      }
})